
const music= {
    //歌曲时间转化
    dataFormate(date) {
        let time
        let str = (((date / 1000)) % 60).toString().substring(0, 2).replace(/(?<=\/|-|\.|:|\b|T)\d{1}(?=\/|-|\.|:|\b|T)/g, "0$&");
        if (str.length == 3) {
            time ='0'+ ((date / 1000) / 60).toString().substring(0, 1) + ':' + str.substring(0, 2);
        } else {
            time ='0'+ ((date / 1000) / 60).toString().substring(0, 1) + ':' + str;
        }
        return time;
    },
    //解析音乐id、name、title等等json数据
    getSongsData(data){
        let SongData=[]
        for(let i=0;i<data.length;i++){
            let obj={}
            if(data[i].alia!=''){
                obj.title=data[i].name+'（'+data[i].alia[0]+')'
            }else {
                obj.title=data[i].name
            }
            obj.name=data[i].ar[0].name
            obj.id=data[i].id
            obj.al=data[i].al.name
            obj.picUrl=data[i].al.picUrl
            obj.pop=data[i].pop
            obj.time=music.dataFormate(data[i].dt)
            obj.vip=data[i].fee
            obj.mvId=data[i].mv
            if(data[i].fee==1){
                obj.vip='[VIP]'
                obj.time='0:30'
            }
            SongData.push(obj)
        }
        return SongData
    }
}

export default music

